<template>
  <div>
    <!-- 路由跳转 -->
    <ul>
      <li><router-link to="/vue2">vue2</router-link></li>
      <li><router-link to="/vue3">vue3</router-link></li>
      <li><router-link to="/vue3-vite">vue3-vite</router-link></li>
    </ul>
    <!-- 加载渲染路由组件 -->
    <router-view></router-view>

    <button @click="login">登录</button>
    <button @click="getState">读取</button>
  </div>
</template>

<script lang="ts" setup>
import tokenActions from "./actions/token.ts";

defineOptions({
  name: "App",
});

const login = () => {
  const token = "1234";
  // 将token保存全局状态中
  tokenActions.setGlobalState({ token });
};

const getState = () => {
  console.log(tokenActions.getGlobalState());
};
</script>

<style scoped lang="scss"></style>
